#define _CRT_SECURE_NO_WARNINGS 1
#include "heap.h"

int main()
{
	HP hp;
	HeapInit(&hp);
	HeapPush(&hp, 4);
	HeapPush(&hp, 19);
	HeapPush(&hp, 46);
	HeapPush(&hp, 17);
	HeapPush(&hp, 22);
	HeapPush(&hp, 3);
	HeapPush(&hp, 9);
	int k = 0;
	scanf("%d", &k);
	while (!HeapEmpty(&hp) && k--)
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}
	printf("\n");

	return 0;
}